
package dao;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import util.ConnectionUtil;

public class ClassDao {

	  // 根据班级名称查询班级的编号
		public static int getClassId(String classname) {
			Connection conn = ConnectionUtil.getConnection();
			String sql = "select class_id FROM classes where class_name like '%" + classname + "%'";
			Statement stat;
			try {
				stat = conn.createStatement();
				ResultSet rs = stat.executeQuery(sql);
				if (rs.next()) {
					int class_id = rs.getInt("class_id");
					return class_id;
				}
			} catch (SQLException e) {
				// TODO: handle exception
				e.printStackTrace();
			}

			return 2001;
		}

	
}
